/*Copyright 2014 Rajesh Putta http://www.codesnippets4all.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
* 
*/

package com.codesnippets4all.jthunder.extension.plugins.input.xml;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.xml.sax.Attributes;

/*
 * @author Rajesh Putta
 */
public class XmlTag {
	private String name;
	private Map<String, String> attributes=new HashMap<String, String>();
	private String body;
	
	private List<XmlTag> children=new ArrayList<XmlTag>();
	
	public void setName(String name) {
		this.name = name;
	}
	
	public String getName() {
		return name;
	}
	
	public void setAttributes(Attributes attributes)
	{
		int size=attributes.getLength();
		
		for(int index=0;index<size;index++)
		{
			String name=attributes.getLocalName(index);
			String value=attributes.getValue(index);
			
			this.attributes.put(name, value);
		}
	}
	
	public Map<String, String> getAttributes()
	{
		return this.attributes;
	}
	
	public void addChild(XmlTag child)
	{
		this.children.add(child);
	}
	
	public List<XmlTag> getChildren() {
		return children;
	}
	
	public void setBody(String body) {
		this.body = body;
	}
	
	public String getBody() {
		return body;
	}
}
